package com.dmall.leetcode307;

import com.dmall.tree.SegmentTree;

public class NumArray2 {

    private SegmentTree<Integer> tree;

    public NumArray2(int[] nums) {
        Integer[] data = new Integer[nums.length];
        tree = new SegmentTree<>(data, (a, b) -> a + b);
    }

    public int sumRange(int i, int j) {
        return tree.query(i, j);
    }

    public void set(int index, int val) {
        tree.set(index, val);
    }
}
